#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:Vergil
# datetime:2018/12/16 19:42
# software: PyCharm
from django import forms
from .models import MusicList, MusicCategory


class UploadForm(forms.ModelForm):
    user = forms.CharField(label='用户', max_length=128, required=False, widget=forms.HiddenInput)
    name = forms.CharField(label='音乐名称', max_length=30, widget=forms.TextInput(attrs={'class': 'form-control rounded input-lg'}))
    is_original = forms.ChoiceField(label='是否原创',choices=((0, '原创'), (1, '转载')),  widget=forms.Select(attrs={'class': 'form-control rounded input-lg'}))
    is_download = forms.ChoiceField(label='是否允许下载', choices=((0, '允许'), (1, '不允许')), widget=forms.Select(attrs={'class': 'form-control rounded input-lg'}))
    category = forms.ModelChoiceField(label='音乐流派', queryset=MusicCategory.objects.all()._values('id'), widget=forms.Select(attrs={'class': 'form-control rounded input-lg'}))
    summary = forms.CharField(label='简介', max_length=200, required=False, widget=forms.TextInput(attrs={'class': 'form-control rounded input-lg'}))
    music_src = forms.FileField(label='音乐文件', widget=forms.FileInput(attrs={'class': 'form-control rounded input-lg'}))
    music_cover = forms.ImageField(label='音乐封面', required=False, widget=forms.FileInput(attrs={'class': 'form-control rounded input-lg'}))

    class Meta:
        model = MusicList
        fields = ('name', 'is_original', 'is_download', 'category', 'summary', 'music_src', 'music_cover',)
